﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;

namespace Warehouse.DataAccess
{
    public partial class Product : CustomeEntity<Product>
    {
        public static Product Empty = new Product()
        {
            ID = 0
        };

        protected override System.Linq.Expressions.Expression<Func<Product, bool>> GetPredicate()
        {
            return p => p.ID == this.ID;
        }

        #region Public Static Methods
        public static Product GetProduct(int ID)
        {
            return GetOne(p => p.ID == ID);
        }

        public static Product GetProduct(string productName, string productModel, string productGrade)
        {
            return GetOne(p => p.Name == productName && p.Model.Equals(productModel) && p.Grade.Equals(productGrade));
        }

        public static Product[] GetProducts()
        {
            return GetList().ToArray();
        }
        #endregion
    }
}
